//手动修改评分界面
import {setAddress} from '../../utils/settings'
Page({
  data: {
    userInfo:{}
  },
  save(data){
    //保存手动添加的分数
    this.data.userInfo.score.turnOverScore = parseInt(data.detail.value.turnOverScore)
    this.data.userInfo.score.sitScore = parseInt(data.detail.value.sitScore)
    this.data.userInfo.score.standScore = parseInt(data.detail.value.standScore)
    this.data.userInfo.score.transferScore = parseInt(data.detail.value.transferScore)
    this.data.userInfo.score.moveScore = parseInt(data.detail.value.moveScore)
    this.data.userInfo.score.upAndDownStairsScore = parseInt(data.detail.value.upAndDownStairsScore)
    this.data.userInfo.score.eatScore = parseInt(data.detail.value.eatScore)
    this.data.userInfo.score.wearScore = parseInt(data.detail.value.wearScore)
    this.data.userInfo.score.bathScore = parseInt(data.detail.value.bathScore)
    this.data.userInfo.score.toiletUsingScore = parseInt(data.detail.value.toiletUsingScore)
    this.data.userInfo.score.communicationScore = parseInt(data.detail.value.communicationScore)
    this.data.userInfo.score.houseworkScore = parseInt(data.detail.value.houseworkScore)
    this.data.userInfo.score.activityScore = parseInt(data.detail.value.activityScore)
    wx.request({
      url: setAddress,
      data: this.data.userInfo,
      method: "POST",
      success:(res)=>{
        wx.setStorageSync("userInfo", this.data.userInfo)
        wx.setStorageSync('changed', 1)
        console.log(wx.getStorageSync("userInfo"))
        wx.navigateBack()
      },
      fail:(err)=>{
        wx.showToast({
          title: '保存失败',
          icon: 'error'
        })
        console.log(err)
      }
    })
    
  },
  onLoad: function () {
    console.log(wx.getStorageSync("userInfo"))
    this.setData({
      userInfo: wx.getStorageSync("userInfo")
    })
  },
})


